#ifndef _DICOM_UPLOAD_CLOUD_UPLOADER_H_
#define _DICOM_UPLOAD_CLOUD_UPLOADER_H_

#include "dicom/upload/same_hash_checker.h"
#include "dicom/upload/resume_info.h"
#include "dicom/file_object.h"
#include "dicom/sync_manager.h"

namespace dicom {

class CloudUploader {
 public:
  CloudUploader(LRUFileCache* fcache, HashCache* hcache);
  ~CloudUploader() {}

  static Status CreateDirInCloud(uint64_t surdoc_key, const std::string& dir_id,
                                 DmvDBPtr& db, std::string* parent_cloud_id);

  Status CheckRapidUpload(uint64_t surdoc_key, const FileObject& fo,
                          const std::string& enc_file_path, bool* rapid,
                          HashEntry* rapidHash);

  Status DoRapidUpload(SDBasic::token::AccessToken& token, const FileObject& fo,
                       const std::string& cloud_parent_id,
                       const HashEntry* hash, SDBasic::tree::TreeEntity* node);

  Status DoUploadSmallFile(SDBasic::token::AccessToken& token,
                           const FileObject& fo,
                           const std::string& cloud_parent_id,
                           const std::string& enc_file_path,
                           const HashEntry* hash,
                           SDBasic::tree::TreeEntity* node);

  Status GetBigFileResumeInfo(SDBasic::token::AccessToken& token,
                              const FileObject& fo, const HashEntry* hash,
                              ResumeInfo* resume_info);

  Status DoUploadBigFile(SDBasic::token::AccessToken& token,
                         const FileObject& fo,
                         const std::string& cloud_parent_id,
                         const std::string& enc_file_path,
                         const HashEntry* hash, ResumeInfo* resume_info,
                         SDBasic::tree::TreeEntity* node);

 private:
  LRUFileCache* fcache_;
  HashCache* hcache_;
};
}

#endif  //_DICOM_UPLOAD_CLOUD_UPLOADER_H_
